package com.yang.web.featuretest.config;

import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.support.WebContentGenerator;

/**
 * @Description:
 * @Author: yangzhiwei
 * @Date: 2021/8/31 17:14
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(setGlobalInterceptor()).addPathPatterns("/**").excludePathPatterns();
        super.addInterceptors(registry);
    }


    @Bean
    public GlobalInterceptor setGlobalInterceptor() {
        return new GlobalInterceptor();
    }
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
        super.addResourceHandlers(registry);
    }


}
